import { simple } from '@/api/hmmm/subjects'
import { simple as secondSimple } from '@/api/hmmm/directorys'
import { simple as tagsSimple } from '@/api/hmmm/tags'
import { choice, detail, choiceCheck, choicePublish, remove, randoms, removeRandoms, add, update } from '@/api/hmmm/questions'
import { simple as UserSimple } from '@/api/base/users'
import { list } from '@/api/hmmm/companys'

const subjects = {
  state: {
    value: '',
    label: ''
  },

  mutations: {
  },

  actions: {
    getSimpleList () {
      return new Promise((resolve, reject) => {
        simple().then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getSecondList ({ commit }, value) {
      return new Promise((resolve, reject) => {
        secondSimple({
          subjectID: value
        }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getTagsList ({ commit }, value) {
      return new Promise((resolve, reject) => {
        tagsSimple({
          subjectID: value
        }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getUserList ({ commit }) {
      return new Promise((resolve, reject) => {
        UserSimple().then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getQuestionList ({ commit }, questionInfo) {
      return new Promise((resolve, reject) => {
        choice(questionInfo).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getPreviewObj ({ commit }, id) {
      return new Promise((resolve, reject) => {
        detail({ id: id }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    setChoiceCheck ({ commit }, auditObj) {
      return new Promise((resolve, reject) => {
        choiceCheck(auditObj).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    setChoicePublish ({ commit }, putTopicObj) {
      return new Promise((resolve, reject) => {
        choicePublish(putTopicObj).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    removeTopic ({ commit }, id) {
      return new Promise((resolve, reject) => {
        remove({ id }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getRandomsList ({ commit }, searchForm) {
      return new Promise((resolve, reject) => {
        randoms(searchForm).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    setRemoveRandoms ({ commit }, id) {
      return new Promise((resolve, reject) => {
        removeRandoms({ id }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    getCompanyList ({ commit }, pagesize) {
      return new Promise((resolve, reject) => {
        list({ pagesize }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    addQuestion ({ commit }, addIssueForm) {
      return new Promise((resolve, reject) => {
        add(addIssueForm).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    updateQuestion ({ commit }, addIssueForm) {
      return new Promise((resolve, reject) => {
        update(addIssueForm).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default subjects
